<?php

defined('BASEPATH') OR exit('No direct script access allowed');


if ( ! function_exists('up_image'))
{
	/**
	 * 上传单张图片
	 *
	 * Opens the file specified in the path and returns it as a string.
	 *
	 * @call_back	图片表单ID name ID
	 * @width	宽度.
	 * @height	高度.
	 * @image	图片 val.
	 * @iframe_class	框架class
	 * @return	string	File contents
	 */
	function up_image($call_back = "image", $width = 100, $height = 100, $image = "",$hz="jpg|png|gif|jpeg",$dir_path = "",$size = 1,$iframe_class = "iframe_class")
	{
		echo '<iframe class="' . $iframe_class .
			'" scrolling="no" frameborder="0" border="0" onload="this.height=this.contentWindow.document.body.scrollHeight;this.width=this.contentWindow.document.body.scrollWidth;" width=' . $width . 
			' height="' . $height . 
			' dir="' . $dir_path . 
			'"  src="' . 
			site_url('upload/uploadpic?'.
				http_build_query(
					array(
						'width' => $width, 
						'height' => $height, 
						'BackCall' => $call_back,
						'dir' => $dir_path,
						//"image" => $image,
						"hz" => $hz,
						"size" => $size,
					)
				) 
			) . '"></iframe>
         <input type="hidden" ' . 'value = "' . $image . '"' . 'name="' . $call_back . '" id="' . $call_back . '">';
	}
}

// ------------------------------------------------------------------------

if ( ! function_exists('up_images'))
{
	/**
	 * 上传多张图片
	 *
	 * Opens the file specified in the path and returns it as a string.
	 *
	 * @call_back	图片表单ID name ID
	 * @width	宽度.
	 * @height	高度.
	 * @image	图片 val.
	 * @iframe_class	框架class
	 * @return	string	File contents
	 */
	function up_images($call_back = "image", $width = 100, $height = 100, $image = "",$hz="jpg|png|gif|jpeg",$dir_path = "",$size = 1,$iframe_class = "iframe_class")
	{
		echo '<iframe class="' . $iframe_class .
			'" scrolling="no" frameborder="0" border="0" width=100% onload="this.height=this.contentWindow.document.body.scrollHeight;"   src="' . 
			site_url('upload/uploadpics?'.
				http_build_query(
					array(
						'width' => $width, 
						'height' => $height, 
						'BackCall' => $call_back,
						'dir' => $dir_path,
						//"image" => $image,
						"hz" => $hz,
						"size" => $size,
					)
				) 
			) . '"></iframe>
         <input type="hidden" ' . 'value = "' . $image . '"' . 'name="' . $call_back . '" id="' . $call_back . '">';
	}
}


if ( ! function_exists('up_file'))
{
	/**
	 * Delete Files
	 *
	 * Deletes all files contained in the supplied directory path.
	 * Files must be writable or owned by the system in order to be deleted.
	 * If the second parameter is set to TRUE, any directories contained
	 * within the supplied base directory will be nuked as well.
	 *
	 * @param	string	$path		File path
	 * @param	bool	$del_dir	Whether to delete any directories found in the path
	 * @param	bool	$htdocs		Whether to skip deleting .htaccess and index page files
	 * @param	int	$_level		Current directory depth level (default: 0; internal use only)
	 * @return	bool
	 */
	function up_file($call_back = "file", $width = 100, $height = 100, $data = "",$size = 1,$hz="jpg|png|gif|jpeg",$dir_path = "",$iframe_class = "iframe_file_class")
	{
		echo '<iframe class="' . $iframe_class .
			'" scrolling="no" frameborder="0" border="0" onload="this.height=this.contentWindow.document.body.scrollHeight;this.width=this.contentWindow.document.body.scrollWidth;" width=' . $width . 
			' height="' . $height . 
			'"  src="' . 
			site_url('upload/uploadfile?'.
				http_build_query(
					array(
						'width' => $width, 
						'height' => $height, 
						'BackCall' => $call_back,
						'dir' => $dir_path,
						"hz" => $hz,
						"size" => $size,
					)
				) 
			) . '"></iframe>
         <input type="hidden" ' . 'value = "' . $data . '"' . 'name="' . $call_back . '" id="' . $call_back . '">';
	}
}

// ------------------------------------------------------------------------

if ( ! function_exists('up_files'))
{
	/**
	 * Get Filenames
	 *
	 * Reads the specified directory and builds an array containing the filenames.
	 * Any sub-folders contained within the specified path are read as well.
	 *
	 * @param	string	path to source
	 * @param	bool	whether to include the path as part of the filename
	 * @param	bool	internal variable to determine recursion status - do not use in calls
	 * @return	array
	 */
	function up_files($source_dir, $include_path = FALSE, $_recursion = FALSE)
	{
		//
	}
}

